﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Helpers;
using DevExpress.XtraBars.Localization;
using PMS.App.Properties;
using PMS.Common;

namespace PMS.App
{
    public partial class frmMain : RibbonForm
    {
        public frmMain()
        {
            InitializeComponent();

            DevExpress.Skins.SkinManager.EnableFormSkins();
            DevExpress.UserSkins.BonusSkins.Register();
            DevExpress.UserSkins.OfficeSkins.Register();
            DevExpress.LookAndFeel.DefaultLookAndFeel obj = new DevExpress.LookAndFeel.DefaultLookAndFeel();
            try
            {
                LookAndFeelSettings.Load("LookAndFeelSettings.dat");
            }
            catch
            {
                obj.LookAndFeel.SetSkinStyle("Office 2007 Blue");
            }
          
        }

        void pnContent_LoadControl(Control control, BarButtonItem barButton, string title)
        {
            pnContent.Controls.Clear();
            pnContent.Controls.Add(control);

            if (barButton.LargeImageIndex != -1)
                pbTitle_Icon.Image = imglistLarge.Images[barButton.LargeImageIndex];
            else
                pbTitle_Icon.Image = imglistSmall.Images[barButton.ImageIndex];
            lblTitle.Text = title;
        }


        private void frmMain_Load(object sender, EventArgs e)
        {
            SkinHelper.InitSkinPopupMenu(barSubItem1);
            pnContent_LoadControl(new ucWarningChart() { Dock = DockStyle.Fill }, barButtonHTThietBi, "OverView");
        }

        private void barButtonHTThietBi_ItemClick(object sender, ItemClickEventArgs e)
        {
            pnContent_LoadControl(new ucComponentHierachy() { Dock = DockStyle.Fill }, barButtonHTThietBi, "Hierachy Component");
        }

        private void pnMain_SizeChanged(object sender, EventArgs e)
        {
            pnContent.Height = pnMain.Height - pnTitle.Height-2;
        }

        private void barButtonNguoiDung_ItemClick(object sender, ItemClickEventArgs e)
        {
            pnContent_LoadControl(new ucUser() { Dock = DockStyle.Fill }, barButtonNguoiDung, "User");
        }

        private void barButtonCauHinh_ItemClick(object sender, ItemClickEventArgs e)
        {
          
        }

        private void barButtonChonTau_ItemClick(object sender, ItemClickEventArgs e)
        {
            pnContent_LoadControl(new ucChooseShip() { Dock = DockStyle.Fill }, barButtonChonTau, "Switch Department");
        }

        private void barButtonDoiMatKhau_ItemClick(object sender, ItemClickEventArgs e)
        {
          
        }

        private void barButtonThongTin_ItemClick(object sender, ItemClickEventArgs e)
        {
           
        }

        private void barButtonTimKiem_ItemClick(object sender, ItemClickEventArgs e)
        {
            pnContent_LoadControl(new ucSearchComponent() { Dock = DockStyle.Fill }, barButtonTimKiem, "Search Component");
        }

        private void barButtonWorkOrder_ItemClick(object sender, ItemClickEventArgs e)
        {
            pnContent_LoadControl(new ucWorkOrders() { Dock = DockStyle.Fill }, barButtonWorkOrder, "Work Orders");
        }

        private void barButtonLog_ItemClick(object sender, ItemClickEventArgs e)
        {
            pnContent_LoadControl(new ucLog() { Dock = DockStyle.Fill }, barButtonLog, "Maintenance Log");
        }

        private void barButtonRequisitionWork_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void barButtonUpdateCounter_ItemClick(object sender, ItemClickEventArgs e)
        {
            pnContent_LoadControl(new ucUpdateCounter() { Dock = DockStyle.Fill }, barButtonUpdateCounter, "Update Counter");
        }

        private void barButtonCounterLog_ItemClick(object sender, ItemClickEventArgs e)
        {
            ucComponentHierachy ucComp = new ucComponentHierachy();
            ucComp.SetValue("s");
            
        }

        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            LookAndFeelSettings.Save("LookAndFeelSettings.dat");
        }

        private void barButtonItemSupplier_ItemClick(object sender, ItemClickEventArgs e)
        {
             pnContent_LoadControl(new ucSupplier() { Dock = DockStyle.Fill }, barButtonWorkOrder, "Supplier");
        }

        private void barButtonItemOffice_ItemClick(object sender, ItemClickEventArgs e)
        {
            pnContent_LoadControl(new ucOffice() { Dock = DockStyle.Fill }, barButtonWorkOrder, "Office");
        }

        private void barButtonItemDepartment_ItemClick(object sender, ItemClickEventArgs e)
        {
            pnContent_LoadControl(new ucDepartment() { Dock = DockStyle.Fill }, barButtonWorkOrder, "Department");
        }

        private void barButtonItemEmployee_ItemClick(object sender, ItemClickEventArgs e)
        {
            pnContent_LoadControl(new ucEmployee() { Dock = DockStyle.Fill }, barButtonWorkOrder, "Employee");
        }

        private void barButtonItemUnits_ItemClick(object sender, ItemClickEventArgs e)
        {
            pnContent_LoadControl(new ucUnit() { Dock = DockStyle.Fill }, barButtonItemUnits, "Units");
        }

        private void barButtonItemTimeUnits_ItemClick(object sender, ItemClickEventArgs e)
        {
            pnContent_LoadControl(new ucTimeUnits() { Dock = DockStyle.Fill }, barButtonItemTimeUnits, "Time Units");
        }

        private void barButtonItemNghiepVu_ItemClick(object sender, ItemClickEventArgs e)
        {
            pnContent_LoadControl(new ucBusiness() { Dock = DockStyle.Fill }, barButtonItemBusiness, "Business");
        }

        private void barButtonItemMantenanceType_ItemClick(object sender, ItemClickEventArgs e)
        {
            pnContent_LoadControl(new ucMantenanceType() { Dock = DockStyle.Fill }, barButtonItemMantenanceType, "Maint Type");
        }

        private void barButtonItemStock_ItemClick(object sender, ItemClickEventArgs e)
        {
            pnContent_LoadControl(new ucStock() { Dock = DockStyle.Fill }, barButtonItemStock, "Stock");
        }

        private void barButtonItemStatus_ItemClick(object sender, ItemClickEventArgs e)
        {
            pnContent_LoadControl(new ucStatus() { Dock = DockStyle.Fill }, barButtonItemStatus, "Machine Status");
        }

        private void barButtonItemMaker_ItemClick(object sender, ItemClickEventArgs e)
        {
            pnContent_LoadControl(new ucMaker() { Dock = DockStyle.Fill }, barButtonItemMaker, "Maker");
        }

       
    }
}